package com.Qinmeiwei.web.controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import com.Qinmeiwei.web.model.User;
import com.Qinmeiwei.web.pojo.Book;

@Controller
public class HomeController extends BaseController {
	
	@RequestMapping(value="/home.html")
	public ModelAndView welcome(HttpServletResponse response, Book book) {
		User user = new User();
		user.setAge(28);
		user.setName("王爱戴");
		
		Map<String, User> map = new HashMap<String, User>();
		map.put("user", user);
		return new ModelAndView("home/home", map);
	}
	
	@RequestMapping(value="/json/alleat.html", method = RequestMethod.POST)
	public void alleat(HttpServletResponse response) {
		response.setContentType("text/html; charset=UTF-8");
        response.setCharacterEncoding("UTF-8");
        response.setHeader("Pragma", "No-cache");
        response.setDateHeader("Expires", 0);
        response.setHeader("Cache-Control", "no-cache");
		PrintWriter out = null;
        try {
            out = response.getWriter();
            out.write("{'code':1,'info':'\\u6210\\u529f\\uff01','data':[{'ShareId':'57447','UserId':'35618','ShopId':'283918','Name':'\\u83dc\\u7b4b\\u584c\\u997c','ShopName':'\\u4fde\\u5bb6\\u996d\\u5e97','total':'6','SubName':'\\u83dc\\u7b4b\\u584c\\u997c','SubShopName':'\\u4fde\\u5bb6\\u996d\\u5e97','EncodeId':23105151,'Img':'http:\\/\\/img1.hoto.cn\\/share\\/67\\/e0\\/57447_175.jpg','UserName':'jinjerry'},{'ShareId':'57435','UserId':'35618','ShopId':'247387','Name':'\\u9999\\u8fa3\\u8c46\\u8150\\u82b1','ShopName':'\\u6731\\u5bb6\\u89d2\\u661f\\u8bb0\\u70b9\\u5fc3\\u5e97','total':'3','SubName':'\\u9999\\u8fa3\\u8c46\\u8150\\u82b1','SubShopName':'\\u6731\\u5bb6\\u89d2\\u661f\\u8bb0\\u70b9','EncodeId':23534890,'Img':'http:\\/\\/img1.hoto.cn\\/share\\/5b\\/e0\\/57435_175.jpg','UserName':'jinjerry'},{'ShareId':'57429','UserId':'35618','ShopId':'283918','Name':'\\u9999\\u9165\\u7f8a\\u6392','ShopName':'\\u4fde\\u5bb6\\u996d\\u5e97','total':'3','SubName':'\\u9999\\u9165\\u7f8a\\u6392','SubShopName':'\\u4fde\\u5bb6\\u996d\\u5e97','EncodeId':23105151,'Img':'http:\\/\\/img1.hoto.cn\\/share\\/55\\/e0\\/57429_175.jpg','UserName':'jinjerry'},{'ShareId':'57264','UserId':'35618','ShopId':'283918','Name':'\\u7ea2\\u70e7\\u725b\\u86d9','ShopName':'\\u4fde\\u5bb6\\u996d\\u5e97','total':'3','SubName':'\\u7ea2\\u70e7\\u725b\\u86d9','SubShopName':'\\u4fde\\u5bb6\\u996d\\u5e97','EncodeId':23105151,'Img':'http:\\/\\/img1.hoto.cn\\/share\\/b0\\/df\\/57264_175.jpg','UserName':'jinjerry'},{'ShareId':'57153','UserId':'478620','ShopId':'283917','Name':'\\u94dc\\u9523\\u70e7','ShopName':'\\u65b0\\u573a\\u6843\\u6e90\\u53f0\\u6e7e\\u7f8e\\u98df\\u8857','total':'2','SubName':'\\u94dc\\u9523\\u70e7','SubShopName':'\\u65b0\\u573a\\u6843\\u6e90\\u53f0\\u6e7e','EncodeId':23105148,'Img':'http:\\/\\/img1.hoto.cn\\/share\\/41\\/df\\/57153_175.jpg','UserName':'\\u6211\\u5bb6\\u7684\\u60a6\\u60a6'},{'ShareId':'57154','UserId':'478620','ShopId':'283917','Name':'\\u81ed\\u8c46\\u8150\\uff08\\u4e0d\\u8fa3\\uff09','ShopName':'\\u65b0\\u573a\\u6843\\u6e90\\u53f0\\u6e7e\\u7f8e\\u98df\\u8857','total':'2','SubName':'\\u81ed\\u8c46\\u8150\\uff08\\u4e0d\\u8fa3','SubShopName':'\\u65b0\\u573a\\u6843\\u6e90\\u53f0\\u6e7e','EncodeId':23105148,'Img':'http:\\/\\/img1.hoto.cn\\/share\\/42\\/df\\/57154_175.jpg','UserName':'\\u6211\\u5bb6\\u7684\\u60a6\\u60a6'},{'ShareId':'57030','UserId':'478620','ShopId':'283897','Name':'\\u9999\\u83c7\\u7626\\u8089\\u7ca5','ShopName':'\\u5305\\u65fa\\u9505\\u8d34\\uff08\\u5468\\u6d66\\u5e97\\uff09','total':'2','SubName':'\\u9999\\u83c7\\u7626\\u8089\\u7ca5','SubShopName':'\\u5305\\u65fa\\u9505\\u8d34\\uff08\\u5468','EncodeId':23105416,'Img':'http:\\/\\/img1.hoto.cn\\/share\\/c6\\/de\\/57030_175.jpg','UserName':'\\u6211\\u5bb6\\u7684\\u60a6\\u60a6'}],'more':[1]}");
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (out != null) {
                out.flush();
                out.close();
            }
        }
	}
	
}
